package com.itheima.utils;

import com.github.wxpay.sdk.WXPayConfig;

import java.io.ByteArrayInputStream;
import java.io.InputStream;


public class PayConfig implements WXPayConfig {


    private String appId;

    private String key;

    private String mchID;

    private byte[] certData;

    public void setAppID(String appId) {
        this.appId = appId;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public void setMchID(String mchID) {
        this.mchID = mchID;
    }

//    //初始化退款、撤销时的商户证书
//    public PayConfig() throws Exception {
//        String certPath = "D://第三方开放平台/wx_apiclient_cert.p12";
//        File file = new File(certPath);
//        InputStream certStream = new FileInputStream(file);
//        this.certData = new byte[(int) file.length()];
//        certStream.read(this.certData);
//        certStream.close();
//    }

    @Override
    public int getHttpConnectTimeoutMs() {
        return 8000;
    }

    @Override
    public int getHttpReadTimeoutMs() {
        return 10000;
    }

    @Override
    public String getAppID() {
        return appId;
    }

    @Override
    public String getMchID() {
        return mchID;
    }

    @Override
    public String getKey() {
        return key;
    }

    @Override
    public InputStream getCertStream() {
        ByteArrayInputStream certBis;
        certBis = new ByteArrayInputStream(this.certData);
        return certBis;

    }


}
